package com.kobe.game_60;

import java.math.BigDecimal;

/**
 * 
 * The series, 11 + 22 + 33 + ... + 1010 = 10405071317.
 * 
 * Find the last ten digits of the series, 11 + 22 + 33 + ... + 10001000.
 * 
 * 
 * 
 */
public class _48 {

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        String result = getResult(1000);
        result = result.substring(result.length() - 10, result.length());
        time = System.currentTimeMillis() - time;

        System.out.println(result);
        System.out.println(time);

    }

    private static String getResult(int number) {
        BigDecimal bd = new BigDecimal(1);
        for (int i = 2; i <= number; i++) {
            BigDecimal tempBd = new BigDecimal(i);
            bd = bd.add(tempBd.pow(i));
        }
        return bd.toString();
    }
}
